package com.example.neusoft215gdh.androidpro_21.Adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;


import com.example.neusoft215gdh.androidpro_21.JavaBean.PostDetail;
import com.example.neusoft215gdh.androidpro_21.R;

import java.util.List;

/**
 * Created by Rainbow on 2017/10/31.
 */

public class PostDetailAdapter extends RecyclerView.Adapter{


    private Context mContext;//承载上下文
    private List<PostDetail> mDataList;//动态数组承载数据使用
    private LayoutInflater mLayoutInflater;

    public PostDetailAdapter(Context mContext, List<PostDetail> mDataList){
        this.mContext=mContext;
        this.mDataList=mDataList;
        mLayoutInflater=LayoutInflater.from(mContext);
    }
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v=mLayoutInflater.from(parent.getContext()).inflate(R.layout.postdetail,parent,false);
        return new PostDetailAdapter.ViewHolder(v);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        final  PostDetail entity=mDataList.get(position);
        if (null==entity)
            return;
        PostDetailAdapter.ViewHolder viewHolder= (PostDetailAdapter.ViewHolder) holder;


//        viewHolder.courseIntro.setText(entity.getIntro());
//        viewHolder.courseNotice.setText(entity.getNotice());
//        viewHolder.time.setText(entity.getUpdate_time());

//        if(!entity.getThumb().isEmpty()) {
//            Picasso.with(mContext).load("http://172.24.10.175/workout/Uploads/" + entity.getThumb()).into(viewHolder.img);
//        }
    }

    @Override
    public int getItemCount() {
        return 0;
    }

    //找到控件，将其初始化
    public class ViewHolder extends RecyclerView.ViewHolder{
        TextView courseIntro;
        TextView courseNotice;
        TextView time;
        ImageView img;
        public ViewHolder(View itemView) {
            super(itemView);
            courseIntro= (TextView) itemView.findViewById(R.id.train_intro);
            courseNotice= (TextView) itemView.findViewById(R.id.courseNotice);
            time= (TextView) itemView.findViewById(R.id.Time);
//            img= (ImageView) itemView.findViewById(R.id.peiXun_img);
        }
    }
}
